<#include "/WEB-INF/default/fragment/nev.ftl">
  
  <!--    <script src="//apps.bdimg.com/libs/jquery/1.10.2/jquery.min.js"></script>
  <link rel="stylesheet" href="//apps.bdimg.com/libs/jqueryui/1.10.4/css/jquery-ui.min.css">
  <script src="//apps.bdimg.com/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>  -->
 <style type="text/css">
   .login_load{width:20px;height:20px; display: none;}
   .login_load.visibe{display: inline-block; }
   .modal{display: none;}
   .choosefile{ margin-left: 192px;margin-top: 51px;} 
 </style>
<div id="main">
            <div align="center"><img src="./assets/image/logo.png" alt=""></div>
        </div>
        <div class="create-poj">
            <form class="form-horizontal" method="post" action="${request.contextPath}/task_publish.action">
                <div class="invit">
                 <span>创建或修改2017-10-31的任务</span>
                 <div class="invit_btn">
                    <button class="btn btn-danger">我的团队</button>
                    <button class="btn btn-success save" type="submit">
                    <img src="./assets/image/loding.gif" class="login_load">保存任务</button>
                 </div>
               </div>
          <!-- <div class="form-group clearfix post-list">
              <label class="post-name fl">所属项目</label>
              <div class="post-value fl">
                  <input type="text" class="form-control" id="inputPassword" 
                   value="" 
                   disabled="disabled">
                  <p class="post-massage">
                      今天（2017-03-31）需要完成的任务名称
                  </p>
              </div>
          </div> -->
                 <div class="form-group clearfix post-list">
                    <label class="post-name fl">任务名称</label>
                    <div class="post-value fl">
                        <input type="text" class="form-control" name="task.title" 
                        value="<#if task?exists && task.title?exists>${task.title}</#if>">
                        <p class="post-massage">
                            今天（2017-03-31）需要完成的任务名称
                        </p>
                         <#if fieldErrors?exists && fieldErrors['task.title']?exists>
                        <p class="help-block"> ${fieldErrors['task.title']!""}</p>
                        </#if>
                    </div>
                </div>
                <div class="form-group clearfix post-list">
                    <label class="post-name fl">任务描述</label>
                    <div class="post-value fl">
                        <input type="text" class="form-control" name="task.desc"
                        value="<#if task?exists && task.title?exists>${task.desc}</#if>">
                        <p class="post-massage">
                            完成任务的补充描述
                        </p>
                         <#if fieldErrors?exists && fieldErrors['task.desc']?exists>
                        <p class="help-block"> ${fieldErrors['task.desc']!""}</p>
                        </#if>
                    </div>
                </div>
                <div class="form-group clearfix post-list">
                    <label class="post-name fl">开始日期</label>
                    <div class="post-value fl">
                        <div class="input-group">
                            <input type="text" class="form-control j_datebegin" name="task.gmtStart"  placeholder="YYYY-MM-DD"
                             value="<#if task?exists && task.gmtStart?exists>${task.gmtStart}</#if>" >
                            <div class="input-group-addon j_datebegin" >
                             <img class="input-add-img" src="./assets/image/date.png">
                            </div>
                        </div>
                        <p class="post-massage">开始执行这个任务的时间</p>
                         <#if fieldErrors?exists && fieldErrors['gmtStart']?exists>
                        <p class="help-block"> ${fieldErrors['gmtStart']!""}</p>
                        </#if>
                    </div>
                </div>
               <div class="form-group clearfix post-list">
                    <label class="post-name fl">超时日期</label>
                    <div class="post-value fl">
                        <div class="input-group">
                            <input type="text" class="form-control j_dateend" name="task.gmtFinished" placeholder="YYYY-MM-DD"
                             value="<#if task?exists&&task.gmtFinished?exists>${task.gmtFinished}</#if>" >
                            <div class="input-group-addon j_dateend" >
                              <img class="input-add-img" src="./assets/image/date.png">
                            </div>
                        </div>
                        <p class="post-massage">任务必须在此日期前完成提交，没有提交则为超时</p>
                            <#if fieldErrors?exists && fieldErrors['task.gmtFinished']?exists>
                        <p class="help-block"> ${fieldErrors['task.gmtFinished']!""}</p>
                        </#if>
                    </div>
                </div>
                <div class="form-group clearfix post-list">
                    <label class="post-name fl">附件</label>
                    <div class="post-value fl">
                        <div class="input-group">
                            <input type="text" class="form-control uploads" id="exampleInputAmount" name="task.attachmentUrl"
                            value="<#if task?exists && task.attachmentUrl?exists>${task.attachmentUrl}</#if>">
                            <div class="input-group-addon btn btn-default up_load">上传文件</div>
                               <#if fieldErrors?exists && fieldErrors['task.attachmentUrl']?exists>
                        <p class="help-block"> ${fieldErrors['task.attachmentUrl']!""}</p>
                        </#if>
                        </div>
                        <p class="post-massage">
                            完成此项任务所需要的附件，素材、参考源码、jar 等，如果是多个文件，请压缩成 zip 格式。
                        </p>
                    </div>
                </div>
        <script type="text/javascript">
        $('.up_load,.uploads').click(function(event) {
            window.location.href='#task_upload';
        });
       </script>
                <div class="form-group clearfix post-list">
                    <label class="post-name fl">提交统计</label>
                    <div class="post-value fl">
                        <table id="table" class="table table-hover">
                            <thead>
                                <tr align="center">
                                    <td>学员姓名</td>
                                    <td>提交时间</td>
                                    <td>是否提交</td>
                                    <td>点赞状态</td>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td>张三</td>
                                    <td>2017-03-06 12：25：01 <a>(三分钟前)</a></td>
                                    <td>已经提交</td>
                                    <td><a class="color1">点赞</a></td>
                                </tr>
                                <tr>
                                    <td>张三</td>
                                    <td>2017-03-06 12：25：01 <a>(三分钟前)</a></td>
                                    <td>已经提交</td>
                                    <td><a class="color4">已点赞</a></td>
                                </tr>
                                <tr>
                                    <td>张三</td>
                                    <td></td>
                                    <td>未提交</td>
                                    <td><a class="color1">提醒</a></td>
                                </tr>
                                <tr>
                                    <td>张三</td>
                                    <td></td>
                                    <td>未提交</td>
                                    <td><a class="color4">已提醒</a></td>
                                </tr>
                            </tbody>
                        </table>
                        <p class="post-massage">
                            完成此项任务所需要的附件，素材、参考源码、jar 等，如果是多个文件，请压缩成 zip 格式。
                        </p>
                    </div>
                </div>
            </form>
        </div>

<div class="remodal" data-remodal-id="task_upload" role="dialog" aria-labelledby="modal1Title" aria-describedby="modal1Desc">
    <button data-remodal-action="close" class="remodal-close" aria-label="Close"></button>
    <div>
        <h2 id="modal1Title">请选择上传文件</h2>
        <div id="modal1Desc">
      <form class="tms-upload-form" action="" method="post" enctype="multipart/form-data">
        <input type="hidden" name="struts.enableJSONValidation" value="true" />
        <!-- <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
          <h4 class="modal-title" id="tmsUploadModalLabel">上传文件</h4>
        </div> -->
        <div class="modal-body">
          <div class="form-group choosefile" >
              <input type="file" id="file" name="file">
              <p class="help-block">&nbsp;</p>
          </div>
          <div class="form-group">
              <label>文件名字</label>
              <input type="text" class="form-control" name="filename">
              <p class="help-block">&nbsp;</p>
          </div>
        </div>
        <div class="modal-footer">
          <button data-remodal-action="confirm" class="remodal-confirm">关闭</button>
          <button type="submit" class="btn btn-primary tms-upload-form-submit remodal-cancel" 
                  data-loading-text="<i class='fa fa-circle-o-notch fa-spin'></i> 正在上传">上传</button>
            <img src="./assets/image/loding.gif" class="login_load ">
          <!-- <button id="btn-project-member" data-remodal-action="cancel" class="remodal-cancel" >
           <img src="./assets/image/loding.gif" class="login_load">上传</button> -->
        </div>
      </form>
    </div>
  </div>
</div>
   <script>
    (function(onSucced) {
  $(document).on('submit', '.tms-upload-form', function() {
    /*$('.tms-upload-form-submit').button('loading');*/
    var formdata = new FormData($(this).get(0));
    jQuery.ajax({
      url: '${request.contextPath}/upload.action?struts.enableJSONValidation=true',
      type: 'POST',
      dataType: 'json',
      data: formdata,
      processData : false,
      contentType: false,
      complete: function(xhr, textStatus) {
        //called when complete
        /*$('.tms-upload-form-submit').button('visibe');*/
      },
      success: function(data, textStatus, xhr) {
        if(data['fieldErrors'] != null) {
          for (var i in data['fieldErrors']) {
            $('input[name="'+i+'"]').next().html(data['fieldErrors'][i]);
          }
          return;
        }
        if (data['status'] === 1) {
          onSucced(data.data);
          $('#tmsUploadModal').modal('hide')
        }
        if (data['status'] === 0) {
          alert(data.message);
        }
      },
      error: function(xhr, textStatus, errorThrown) {
        console.log(xhr, textStatus, errorThrown);
      }
    });

    return false;
  });
})(function(url) {
  $('input[name="task.attachmentUrl"]').val(url);
});
   
     /* $(function(){
       $('.j_datebegin, .j_dateend').datepicker({
          showButtonPanel: true,
          showOtherMonths: true,
          selectOtherMonths: true
       });
       
    });
       */
   </script>
<#include "/WEB-INF/default/fragment/footer.ftl">